# Nitro SCONS file

# IMPORT
import zipfile, os

# CONFIGURATION
FILES = "Build/Scons/Application.cpp Build/Scons/Car.cpp Build/Scons/CarResources.cpp Build/Scons/GameEngine.cpp Build/Scons/Level.cpp Build/Scons/main.cpp Build/Scons/MapElement.cpp Build/Scons/MapTile.cpp Build/Scons/Memory.cpp Build/Scons/Preferences.cpp Build/Scons/Screen.cpp Build/Scons/Tile.cpp Build/Scons/Tools.cpp Build/Scons/WorldDisplay.cpp Build/Scons/Maths/unit_tests.cpp"
CCFLAGS = "-Wall `pkg-config --cflags clanCore-2.0 clanDisplay-2.0 clanApp-2.0 clanGL1-2.0 clanGL-2.0 clanGDI-2.0 clanSDL-2.0` -g -D DEBUG"
LIBS = "pkg-config --libs clanCore-2.0 clanDisplay-2.0 clanApp-2.0 clanGL1-2.0 clanGL-2.0 clanGDI-2.0 clanSDL-2.0 clanSound-2.0 clanVorbis-2.0"

INCLUDES_TO_CHECK = "vector list ClanLib/core.h ClanLib/application.h ClanLib/gl.h ClanLib/display.h"
LIBS_TO_CHECK = "clanCore clanDisplay clanSignals clanApp clanGL clanSDL"


# CONFIGURING ENVIRONNEMENT
env = Environment()
env.ParseConfig(LIBS)
conf = Configure(env)

env = conf.Finish()

# BUILIND THE SOFTWARE
BuildDir('Build/Scons', 'src')
env.Program('nitro', Split(FILES), CCFLAGS=CCFLAGS)


# FUNCTION TO MAKE ZIP 
def zipFile(dir):
        oldpath = os.getcwd()
        f = zipfile.ZipFile(dir+'.zip','w',zipfile.ZIP_DEFLATED)
        os.chdir(dir)
        for root, dirs, files in os.walk('.'):
                if '.sconsign' in files:
                        files.remove('.sconsign')
                
                for afile in files:
                        rroot = root[2:]
                        if not rroot:
                                f.write(afile)
                        else:
                                #print root[2:]+"/"+afile
                                aafile = root[2:]+"/"+afile
                                f.write(aafile)
                
                if '.svn' in dirs:
                        dirs.remove('.svn')  # don't visit SVN directories
        f.close()
        os.chdir(oldpath)
        print dir+" zip created"






